package com.fx.commonuntils.guavauntils;

import com.fx.commonuntils.ErrorEnum;
import com.google.common.base.Preconditions;
import org.apache.commons.lang3.StringUtils;

public class CheckParamUtils {


    //校验如此不为空或者null，否则返回错误信息
    public static void isNotNullAndEmty(String field, String fieldDes) throws IllegalStateException {
        Preconditions.checkState(StringUtils.isNotBlank(field)&&StringUtils.isNotEmpty(field), fieldDes + ErrorEnum.E_PARAM_CHARK.getErrorMsg());
    }
    //校验service层不为空或者null
    public static void isNotNullAndEmty(String field) throws IllegalStateException {
        Preconditions.checkState(StringUtils.isNotBlank(field)&&StringUtils.isNotEmpty(field));
    }

    public static void isNotZero(Integer field, String fieldDes) throws IllegalStateException {
        Preconditions.checkState(field != null && field > 0, fieldDes  + ErrorEnum.E_PARAM_CHARK.getErrorMsg());
    }

    public static void argument(String field, String fieldDes) throws IllegalStateException {
        Preconditions.checkArgument(StringUtils.isNotBlank(field)&&StringUtils.isNotEmpty(field), fieldDes + ErrorEnum.E_PARAM_CHARK.getErrorMsg());
    }




}
